<template>
  <div class="hello">
    <!--组件插槽-->
    <slot name="header">插槽内容</slot>
    <!--为插槽绑定数据，名为d-->
    <slot name="footer" :d="childCount">插槽默认内容</slot>
    <!-- <h1>{{ msg }}</h1>
    <p>props中的{{count}}</p> -->
    <button @click="handler">按钮</button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  //组件通信，父传子
  props: {
    msg: String,
    count:{
      type:String,
      requred:true
    }
  },
  data(){
    return{
      childCount:1000
    }
  },
  methods:{
    handler(){
      this.childCount++
      //子组件向父组件传参,通过自定义事件
      //child-count-change事件发生时,把childCount的值传递给父组件
      this.$emit('child-count-change',this.childCount)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
